import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { ApiProperty } from '@nestjs/swagger';
import { Document } from 'mongoose';

export type ProductDocument = Product & Document;

@Schema()
export class Product extends Document {
  @Prop({
    required: true,
  })
  @ApiProperty({
    description: '手机品牌',
    example: 'vivo',
  })
  readonly brand: string;

  @Prop({
    required: true,
  })
  @ApiProperty({
    description: '型号',
    example: 'x21',
  })
  readonly model: string;

  @Prop({
    required: true,
  })
  @ApiProperty({
    description: '库存数量',
    example: '10',
  })
  count: number;

  @Prop({
    required: true,
  })
  @ApiProperty({
    description: '运行内存',
    example: '6G',
  })
  readonly ram: string;

  @Prop({
    required: true,
  })
  @ApiProperty({
    description: '存储空间',
    example: '256G',
  })
  readonly storage: string;

  @Prop({
    required: true,
  })
  @ApiProperty({
    description: '颜色',
    example: '黑色',
  })
  readonly color: string;

  @Prop({
    required: true,
  })
  @ApiProperty({
    description: '不同手机的串码',
    example: '["xxxxxxxxxxxxxxxx"]',
  })
  imei: string[];
}

export const ProductSchema = SchemaFactory.createForClass(Product);
